function residual = static_resid(T, y, x, params, T_flag)
% function residual = static_resid(T, y, x, params, T_flag)
%
% File created by Dynare Preprocessor from .mod file
%
% Inputs:
%   T         [#temp variables by 1]  double   vector of temporary terms to be filled by function
%   y         [M_.endo_nbr by 1]      double   vector of endogenous variables in declaration order
%   x         [M_.exo_nbr by 1]       double   vector of exogenous variables in declaration order
%   params    [M_.param_nbr by 1]     double   vector of parameter values in declaration order
%                                              to evaluate the model
%   T_flag    boolean                 boolean  flag saying whether or not to calculate temporary terms
%
% Output:
%   residual
%

if T_flag
    T = bbeffectivedemandmatchirf_order3.static_resid_tt(T, y, x, params);
end
residual = zeros(30, 1);
lhs = y(26)+params(15);
rhs = T(1)*T(2);
residual(1) = lhs - rhs;
lhs = y(2)+y(10)*params(14)/y(18);
rhs = y(10)*params(14)+y(12)*y(25)+y(3);
residual(2) = lhs - rhs;
lhs = y(25);
rhs = y(2)*(1-params(6))/params(6)/(1-y(12));
residual(3) = lhs - rhs;
lhs = y(23);
rhs = T(5)^(params(12)/(1-params(9)));
residual(4) = lhs - rhs;
lhs = y(8);
rhs = T(6);
residual(5) = lhs - rhs;
lhs = y(12)*y(25);
rhs = (y(26)+params(15))*(1-params(1))/y(11);
residual(6) = lhs - rhs;
lhs = y(10)*y(21)*y(19);
rhs = (y(26)+params(15))*params(1)/y(11);
residual(7) = lhs - rhs;
lhs = y(10)*y(21)*y(16)*y(5);
rhs = (y(26)+params(15))*params(1)/y(11);
residual(8) = lhs - rhs;
lhs = y(10);
rhs = y(9)+y(10)*T(8);
residual(9) = lhs - rhs;
lhs = y(4);
rhs = params(3)+params(4)*(y(21)-1)+params(5)/2*(y(21)-1)^2;
residual(10) = lhs - rhs;
lhs = y(5);
rhs = params(4)+(y(21)-1)*params(5);
residual(11) = lhs - rhs;
lhs = y(20);
rhs = params(2)*(T(6)/y(8))^(1-1/params(12));
residual(12) = lhs - rhs;
lhs = 1;
rhs = y(18)*y(20);
residual(13) = lhs - rhs;
lhs = 1;
rhs = T(10);
residual(14) = lhs - rhs;
lhs = 1;
rhs = y(20)*(y(3)+y(13))/y(13);
residual(15) = lhs - rhs;
lhs = log(y(17));
rhs = (1-params(16))*(log(params(41))+params(17)*log(T(11)))+log(y(17))*params(16);
residual(16) = lhs - rhs;
lhs = y(3);
rhs = y(26)-y(12)*y(25)-y(9)-y(26)*T(12)-params(14)*(y(10)-y(10)/y(18));
residual(17) = lhs - rhs;
lhs = 1;
rhs = y(20)*(y(21)*y(19)+y(16)*(T(8)+T(7)*T(13)))/y(16);
residual(18) = lhs - rhs;
lhs = 1/y(16);
rhs = 1-T(13);
residual(19) = lhs - rhs;
lhs = T(11)*params(7)*(T(11)-1);
rhs = 1-params(13)+params(13)/y(11)+T(11)*(T(11)-1)*y(20)*params(7);
residual(20) = lhs - rhs;
lhs = y(15);
rhs = y(26)*(y(11)-1)-params(15);
residual(21) = lhs - rhs;
lhs = y(6);
rhs = (y(3)+y(13))/y(13);
residual(22) = lhs - rhs;
lhs = y(7);
rhs = T(14)/T(15);
residual(23) = lhs - rhs;
lhs = y(22);
rhs = y(7)-y(6)^2;
residual(24) = lhs - rhs;
lhs = y(1);
rhs = (1-params(19))*params(25)+y(1)*params(19)+y(24)*x(1);
residual(25) = lhs - rhs;
lhs = y(24);
rhs = y(24)*params(20)+(1-params(20))*params(48)+params(21)*x(2);
residual(26) = lhs - rhs;
lhs = y(27);
rhs = (1-params(22))*params(52)+y(27)*params(22)+params(49)*x(3);
residual(27) = lhs - rhs;
lhs = y(28);
rhs = 1-T(10);
residual(28) = lhs - rhs;
lhs = y(29);
rhs = 1-y(18)*y(20);
residual(29) = lhs - rhs;
lhs = y(30);
rhs = T(11)*params(7)*(T(11)-1)-(1-params(13)+params(13)/y(11)+T(11)*(T(11)-1)*y(20)*params(7));
residual(30) = lhs - rhs;
if ~isreal(residual)
  residual = real(residual)+imag(residual).^2;
end
end
